/**
 * @Time    : 2021/11/12 11:50:15
 * @Author  : WanRongJia
 * @License : Software business license
 * @Site    : www.linshensjl.top
 * @File    : validateAddClerk.js
 * @Software: Rich Web Platform
 * @Function: 验证注册用户字段
 * @Version : 1.0
 **/

const { validateResult } = require("../../../utils/validationResult");
const { check } = require("express-validator");

const validateMenuInsert = [
	check("pid").optional().isString().withMessage("必须是字符"),
	check("title")
		.exists()
		.withMessage("必须传入标题")
		.notEmpty()
		.withMessage("不可为空")
		.isString()
		.withMessage("必须是字符"),
	check("type")
		.exists()
		.withMessage("必须传入类型")
		.notEmpty()
		.withMessage("不可为空")
		.isString()
		.withMessage("必须是字符"),
	check("name").optional().isString().withMessage("必须是字符"),
	check("path").optional().isString().withMessage("必须是字符"),
	check("desc").optional().isString().withMessage("必须是字符"),
	check("icon").optional().isString().withMessage("必须是字符"),
	check("is_show").optional().isBoolean().withMessage("必须是布尔类型"),
	(req, res, next) => {
		validateResult(req, res, next);
	},
];

module.exports = { validateMenuInsert };
